package com.mightybird.designpattern.structural.proxy;

public class ProxySearcher implements Searcher{
    private AccessValidator validator = new AccessValidator();
    private SearchLogger logger = new SearchLogger();
    private RealSearcher realSearcher = new RealSearcher();

    @Override
    public String doSearch(String userId, String keyword) {
        if (validator.validate(userId)) {
            logger.logInfo(userId);
            return realSearcher.doSearch(userId, keyword);
        } else {
            logger.logError(userId);
            return null;
        }
    }
}
